package com.anis.project.medcare.command.handler;

import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.IHandler;
import org.eclipse.core.commands.IHandlerListener;
import org.eclipse.ui.PartInitException;

import com.anis.jpa.medical.model.MedicalReport;
import com.anis.project.medcare.Activator;
import com.anis.project.medcare.editors.ReportEditor;
import com.anis.project.medcare.editors.input.ReportEditorInput;

public class NewReportHandler implements IHandler {

	@Override
	public void addHandlerListener(IHandlerListener handlerListener) {
		// TODO Auto-generated method stub

	}

	@Override
	public void dispose() {
		// TODO Auto-generated method stub

	}

	@Override
	public Object execute(ExecutionEvent event) throws ExecutionException {
		MedicalReport radioReport = new MedicalReport();
		ReportEditorInput radioReportInput = new ReportEditorInput(
				radioReport);
		try {
			Activator.getDefault().getWorkbench()
					.getActiveWorkbenchWindow().getActivePage()
					.openEditor(radioReportInput, ReportEditor.ID);
		} catch (PartInitException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public boolean isEnabled() {
		return Activator.getDefault().isConnectiontoDB();
	}

	@Override
	public boolean isHandled() {
		return true;
	}

	@Override
	public void removeHandlerListener(IHandlerListener handlerListener) {
		// TODO Auto-generated method stub

	}

}
